package com.itheima;

public class ArrayDemo09 {
    public static void main(String[] args) {
        int[] arr = {11, 22, 44, 5, 33,};
        int min = getMinAndMax(arr)[0];
        int max = getMinAndMax(arr)[1];
        System.out.println(min);
        System.out.println(max);
    }

    public static int[] getMinAndMax(int[] arr) {
        int max = arr[0];
        for (int i = 1; i < arr.length; i++) {
            if (max < arr[i]) {
                max = arr[i];
            }
        }
        int min = arr[0];
        for (int i = 1; i < arr.length; i++) {
            if (min > arr[i]) {
                min = arr[i];
            }
        }
        int[] getMinAndMax = {min, max};
        return getMinAndMax;
    }
}
